{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c4f56e9a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "0195159a",
   "metadata": {},
   "outputs": [],
   "source": [
    "data_predict = pd.read_csv('./predict_result.csv')\n",
    "data = pd.read_csv('./fund_apply_redeem_series_0701.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "24ddf007",
   "metadata": {},
   "outputs": [],
   "source": [
    "predict_date = 20250701\n",
    "data_predict = data_predict[data_predict.transaction_date==predict_date]\n",
    "data = data[data.transaction_date==predict_date]\n",
    "real_values = data[['apply_amt','redeem_amt']].values\n",
    "predict_values = data_predict[['apply_amt', 'redeem_amt']].values\n",
    "\n",
    "scores = np.abs((real_values-predict_values)/real_values)\n",
    "weights = real_values/real_values.sum(axis=0)\n",
    "score = np.mean(scores*weights,axis = 0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "9b003dce",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0.09063005 0.04944294]\n",
      " [0.48261946 0.15818875]\n",
      " [0.76778356 0.15788907]\n",
      " [0.46728416 0.23192288]\n",
      " [0.01346357 0.63330333]\n",
      " [0.30108808 0.30889531]\n",
      " [0.50215575 0.12990745]\n",
      " [0.95845661 0.56229459]\n",
      " [0.45115143 0.37760844]\n",
      " [0.34990529 0.8030911 ]\n",
      " [0.5048478  0.1990891 ]\n",
      " [0.15606729 0.12546037]\n",
      " [0.27153158 0.25882418]\n",
      " [0.66169733 0.86869082]\n",
      " [0.01620314 0.25126528]\n",
      " [0.72816888 0.84245049]\n",
      " [0.5651874  0.26630541]\n",
      " [0.94477909 0.71354828]\n",
      " [0.63692114 0.53482333]\n",
      " [0.52574094 0.08191398]]\n",
      "[0.02686024 0.02570998]\n"
     ]
    }
   ],
   "source": [
    "print(scores)\n",
    "print(score)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1ae90ca6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 3135.74064009,  6719.7294126 ],\n",
       "       [ 6174.04335488,  4030.18852658],\n",
       "       [ 4135.65052127,  2654.27080967],\n",
       "       [ 4253.94590627,  2459.81937866],\n",
       "       [ 4520.68861427,  2706.36731888],\n",
       "       [ 4001.14803958,  4168.47927069],\n",
       "       [ 8466.19060989,  5536.9018085 ],\n",
       "       [13326.25536605, 11032.16299702],\n",
       "       [ 2312.33914828,  2304.87242073],\n",
       "       [ 5254.60185637,  5789.06197379],\n",
       "       [21566.85341234, 13133.41106676],\n",
       "       [ 3659.30207908,  3147.93888981],\n",
       "       [ 2166.45880124,  2283.57086863],\n",
       "       [ 4218.98180564,  5049.27074357],\n",
       "       [10618.76498307, 19071.16618617],\n",
       "       [ 4889.272289  ,  6076.86040374],\n",
       "       [ 6539.65915658, 14889.01087052],\n",
       "       [30327.04665059, 38048.93453459],\n",
       "       [ 5882.49453926,  5113.97627621],\n",
       "       [20799.07655944, 18653.61506506]])"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1129bfde",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
